<?php

!defined('IN_HDWIKI') && exit('Access Denied');

class control extends base{

	function control(& $get,& $post){
		$this->base( & $get,& $post);
		$this->loadplugin('hdapi');
	}

	function dodefault(){
		$len=strlen('plugin-hdapi-hdapi-default-');
		$title=substr($_SERVER['QUERY_STRING'],$len);
		$title = urldecode($title);
		if(strtolower(WIKI_CHARSET) == 'gbk'){$title = string::hiconv($title,'gbk','utf-8');}
		if($title){
			$doc = $_ENV['hdapi']->get_doc_by_title($title);
			if(is_array($doc)){
				$this->setting['date_format'] = "Y-m-d";
				$this->setting['time_format'] = "H:i:s";
				$his = $_ENV['hdapi']->get_recent_editon_info($doc['did']);
				if(strtolower(WIKI_CHARSET) == 'gbk'){
					$doc['content'] = string::hiconv($doc['content'],'utf-8','gbk');
					$doc['author'] = string::hiconv($doc['author'],'utf-8','gbk');
					$his['reason'] = string::hiconv($his['reason'],'utf-8','gbk');
					$doc['lasteditor'] = string::hiconv($doc['lasteditor'],'utf-8','gbk');
					$doc['title'] = string::hiconv($doc['title'],'utf-8','gbk');
				}
				$output = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>
	            <ROOT>
	            <DOC_TITLE><![CDATA[".$doc['title']."]]></DOC_TITLE>
	            <DOC_TEXT><![CDATA[".$doc['content']."]]></DOC_TEXT>
	            <DOC_LATEST_EDITION><![CDATA[".$his["eid"]."]]></DOC_LATEST_EDITION>
	            <DOC_CREATOR_USER_NICK><![CDATA[".$doc['author']."]]></DOC_CREATOR_USER_NICK>
	            <DOC_CREATED_TIME><![CDATA[".$this->date($doc['time'])."]]></DOC_CREATED_TIME>
	            <DOC_LATEST_EDITION_TIME><![CDATA[".$this->date($doc['lastedit'])."]]></DOC_LATEST_EDITION_TIME>
				<DOC_HIS_EDIT_REASON><![CDATA[".$his['reason']."]]></DOC_HIS_EDIT_REASON>
				<DOC_HIS_EDITOR_USER_NICK><![CDATA[".$doc['lasteditor']."]]></DOC_HIS_EDITOR_USER_NICK>
				</ROOT>";
				echo $output;
			}else{
				exit();
			}
		}else{
			exit();
		}
	}
}

?>